package com.lbn.baseframe.net.business;

import com.lbn.baseframe.utils.L;

import rx.Subscriber;

/**
 * Created by Administrator on 2016/8/15.
 */
public abstract class RxSubscribe<T> extends Subscriber<T> {

    @Override
    public void onStart() {
        super.onStart();
        //可以在onStart里面搞事~
    }

    @Override
    public void onCompleted() {
        if(isUnsubscribed()){
            unsubscribe();
        }
    }

    @Override
    public void onNext(T t) {
        next(t);
    }

    @Override
    public void onError(Throwable e) {
        e.printStackTrace();
        error(e);
        L.e("RxError:" + e.getMessage());
        if(isUnsubscribed()){
            unsubscribe();
        }
    }

    public abstract void next(T t);

    public abstract void error(Throwable e);

}